/**
 * @file   frame_header.hh
 * @author Pedro
 * @date   Thu Nov  6 12:22:51 2008
 * 
 * @brief  Definición de las cabeceras para los archivos de video, y funciones necesarias
 * 
 * 
 */
#ifndef _FRAME_HEADER_HH_
#define _FRAME_HEADER_HH_

#include <stdio.h>

#include "cxcore.h"

#define FRAME_START_CODE 0xFF00


typedef struct frame_headerv1{
    unsigned int start_code; //0xFF00
    unsigned int version;
    unsigned int nframe;
    unsigned int counter;
    unsigned int width;
    unsigned int height;
    unsigned int ncameras;
    char color_space[4];
    unsigned int fps;
    unsigned int shutter;
    unsigned int gain;
    unsigned int brightness;
    unsigned int lighting;
}frame_headerv1;

typedef struct frame_headerv2{
    unsigned int start_code; //0xFF00
    unsigned int version; // 2
    unsigned int nframe;
    unsigned int counter;
    int width;
    int height;
    unsigned int ncameras;
    char color_space[4];
    unsigned int fps;
    unsigned int shutter_usec;
    unsigned int gain;
    unsigned int brightness;
    unsigned int lighting;
    struct timeval filltime;
}frame_headerv2;

typedef frame_headerv2 frame_header;

int read_frame_header_version(FILE *f);
int read_frame_header(FILE *f, struct frame_headerv1 *head);
int read_frame_header(FILE *f, struct frame_headerv2 *head);
int check_frame_header(const IplImage *img, unsigned int frame, struct frame_headerv1* hout);
// int write_frame_header(const IplImage *img, int nframe, int ncameras, int fps);

#endif
